package com.mobile.service.convert;

import com.mobile.service.dto.AuthDTO;
import com.mobile.service.dto.OrganizationDTO;
import com.mobile.service.entity.Auth;
import com.mobile.service.entity.Organization;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;

import java.util.List;
import java.util.stream.Collectors;

@Mapper(componentModel = "spring")
public interface OrganizationConverter {

    // 基础映射
    Organization toEntity(OrganizationDTO dto);

    // 反向映射
    @InheritInverseConfiguration
    OrganizationDTO toDto(Organization entity);

    // 集合映射
    default List<OrganizationDTO> toDtoList(List<Organization> entities) {
        return entities.stream()
                .map(this::toDto)
                .collect(Collectors.toList());
    }
}
